package com.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/user")
public class loginController {

    @RequestMapping("/main")
    public String main(){
        return "main";
    }

    @RequestMapping("/goLogin")
    public String login(){
        return "login";
    }


    @RequestMapping("/login")
    public String login(HttpSession session, String username, String password, Model model){
        //将用户信息设置到session中
       session.setAttribute("userLogInfo",username);
       model.addAttribute("username",username);
        return "main";
    }

    //就是用户注销,退出登录,删除用户session里的信息即可
    @RequestMapping("/goOut")
    public String goOut(HttpSession session){
        session.removeAttribute("userLogInfo");
      //  session.invalidate();  这个方法是永远删除用户的session,一般不用这个方法
        return "main";
    }

}
